#pragma once
#include "d3dApp.h"
#include <tchar.h>
#include <crtdbg.h>
#include "GfxStats.h"
#include "DInput.h"
#include <time.h>
#include "dsound.h"
#include "Ball.h"
#include "Vertex.h"
#include <vector>
using namespace std;

class GSP320 : public D3DApp
{

public:
	GSP320(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP);
	~GSP320();

	/********************Needed for any program you instantiate***************************/
	bool checkDeviceCaps();
	void onLostDevice();
	void onResetDevice();
	void updateScene(float dt);
	void drawScene();
	/*************************************************************************************/

	//the one and only sprite interface through which we do all of our sprite drawing
	ID3DXSprite* mSprite;

	//camera and matrix build functions
	void buildViewMtx();
	void buildProjMtx();

	
private:
	GfxStats* mGfxStats;	
	ID3DXFont* mFont;
	Ball* ball;
	
	//camera stuffs and others
	float mCameraRotationY;
	float mCameraRadius;
	float mCameraHeight;

	D3DXMATRIX mView;
	D3DXMATRIX mProj;

	//effects object and buffer object for effect
	ID3DXEffect* mFX;

	//handles for technique and world, view, proj matrices (combined)
	D3DXHANDLE mhTech;
	D3DXHANDLE mhWVP;
	
	void setupFX();
	void cleanUp();	
	void display();
	//variables needed for the grid
	IDirect3DVertexBuffer9* mVB;
	IDirect3DIndexBuffer9*  mIB;
	DWORD mNumVertices;
	DWORD mNumTriangles;

	//functions to generate our ground grid
	void generateGrid(int numVertRows, int numVertCols,float dx, float dz, const D3DXVECTOR3& center,
	std::vector<D3DXVECTOR3>& verts, std::vector<DWORD>& indices);
	void buildBuffers();
	void drawGrid();
	void ballSetup();
	bool gameStart;
};
